package com.example.repeatsubmit.config;

import com.example.repeatsubmit.interceptor.AuthenticationInterceptor;
import com.example.repeatsubmit.interceptor.RepeatInterceptor;
import com.example.repeatsubmit.interceptor.TestInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.LinkedList;

/**
 * @author caoqianhuan
 * @date 2022/8/19
 * @Description:
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Resource
    RepeatInterceptor repeatInterceptor;
    @Resource
    private AuthenticationInterceptor authenticationInterceptor;

    @Resource
    private TestInterceptor testInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(testInterceptor).addPathPatterns("/*");
        registry.addInterceptor(repeatInterceptor).addPathPatterns("/*").excludePathPatterns("/error");

//        registry.addInterceptor(authenticationInterceptor).addPathPatterns("/*").excludePathPatterns("/error", "/d");

        registry.addInterceptor(authenticationInterceptor).addPathPatterns("/*").excludePathPatterns("/error", "/d", "/e", "/m", "/logout");

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
